package core;

import parsing.ParsingTools;


public class Country implements Comparable<Country>{

	int countryId;
	int continentId;
	String countryName;
	
	public Country(String countryId, String continentId, String countryName){
		this.countryName=countryName;
		int continentID=ParsingTools.GetCountryIDFromCode(continentId);
		int countryID = ParsingTools.GetCountryIDFromCode(countryId);
		this.continentId=continentID;
		this.countryId=countryID;
		
	}
	
	//Constructor For Simulation
	public Country(int continentID, int countryID, String countryName){
		this.countryName=countryName;
		this.continentId=continentID;
		this.countryId=countryID;
		
	}
	
	public int getCountryId() {
		return countryId;
	}

	public void setCountryId(int countryId) {
		this.countryId = countryId;
	}

	public int getContinentId() {
		return continentId;
	}

	public void setContinentId(int continentId) {
		this.continentId = continentId;
	}

	public String getCountryName() {
		return countryName;
	}

	public void setCountryName(String countryName) {
		this.countryName = countryName;
	}


	@Override
	public boolean equals(Object obj) {
		if (obj == this) {
			return true;
		}
		if (!(obj instanceof Country)) {
			return false;
		}
		Country other = (Country) obj;
		if ((this.countryId == other.countryId)
				&& (this.countryName.equals(other.countryName) &&(this.continentId==other.continentId))) {
			return true;
		} else {
			return false;
		}
	}
	
	@Override
	public int hashCode() {
		int hash = 17;
		hash = 37*hash + (this.countryName != null ? this.countryName.hashCode()
						: 0);
		hash = 37 * hash + this.continentId;
		hash = 37 * hash +this.countryId;
		return hash;
	}
	@Override
	public int compareTo(Country that) {
		int nameDiff = this.countryName
				.compareToIgnoreCase(that.countryName);
		long result = nameDiff;
		if (result == 0) {/* Debug to check if the id returns correct */
			result = this.countryId - that.countryId;
		}
		if (result ==0){
			result=this.continentId-that.continentId;
		}
		return Long.signum(result);
	}

}
